]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st/scroll-view: Hide scroll bar from layout when its hidden
authorJonas Dreßler <verdre@v0yd.nl>
Wed, 16 Feb 2022 15:16:49 +0000 (16:16 +0100)
committerJonas Dreßler <verdre@v0yd.nl>
Sat, 18 Nov 2023 11:22:51 +0000 (12:22 +0100)
We hide scrollbars with POLICY_AUTOMATIC when the content of the scroll
view fits completely inside the view without having to scroll. In this case
it seems like a good idea to give the content the full available size
without subtracting scroll bars from that size.

So subtract the scroll bar from the size we give to the child only when
the scroll bar is actually visible, when it's invisible subtract 0 instead.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2190>

src/st/st-scroll-view.c

index f278568dc0903e24f605d3873bfc3841f460a542..3313307deb32e624cc6812181f00eaa87588e663 100644 (file)
@@ -636,19 +636,14 @@ st_scroll_view_allocate (ClutterActor          *actor,
       clutter_actor_allocate (priv->hscroll, &empty_box);
     }
 
-  /* In case the scrollbar policy is NEVER or EXTERNAL or scrollbars
-   * should be overlaid, we don't trim the content box allocation by
-   * the scrollbar size.
+  /* In case the scrollbar is hidden or scrollbars should be overlaid,
+   * we don't trim the content box allocation by the scrollbar size.
    * Fold this into the scrollbar sizes to simplify the rest of the
    * computations.
    */
-  if (priv->hscrollbar_policy == ST_POLICY_NEVER ||
-      priv->hscrollbar_policy == ST_POLICY_EXTERNAL ||
-      priv->overlay_scrollbars)
+  if (!hscrollbar_visible || priv->overlay_scrollbars)
     sb_height = 0;
-  if (priv->vscrollbar_policy == ST_POLICY_NEVER ||
-      priv->vscrollbar_policy == ST_POLICY_EXTERNAL ||
-      priv->overlay_scrollbars)
+  if (!vscrollbar_visible || priv->overlay_scrollbars)
     sb_width = 0;
 
   /* Child */